home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / TGCBOR20.ARJ / INTROPAK.COM / TIMETICK.C < prev    next >
Text File  |  1991-04-25  |  999b  |  58 lines

  1.  
  2. #include <teglsys.h>
  3.  
  4. unsigned secs  = 0;
  5. unsigned mins  = 0;
  6. unsigned hours = 0;
  7. imagestkptr timefs;
  8.  
  9. unsigned inc_time(imagestkptr frame,msclickptr mouseclickpos)
  10. {
  11.   char *ptr;
  12.   char strings[40];
  13.  
  14.   ++secs;
  15.   if (secs > 59) {
  16.     secs = 0;
  17.     ++mins;
  18.     if (mins > 59) {
  19.       mins = 0;
  20.       ++hours;
  21.       if (hours > 23) {
  22.     hours = 0;
  23.       }
  24.     }
  25.   }
  26.  
  27.   ptr = strings;
  28.   sprintf(ptr,"%2d:%2d:%2d",hours,mins,secs);
  29.   if (hours < 10)              /* fill in leading zeros */
  30.     ptr[0] = '0';
  31.   if (mins < 10)
  32.     ptr[3] = '0';
  33.   if (secs < 10)
  34.     ptr[6] = '0';
  35.  
  36.   prepareforupdate(timefs);
  37.   shadowbox(timefs->x,timefs->y,timefs->x1,timefs->y1);
  38.   setcolor(BLACK);
  39.   outtegltextxy(timefs->x+5,timefs->y+2,ptr);
  40.   commitupdate();
  41.  
  42.   return 0;
  43. }
  44.  
  45.  
  46. void main()
  47. {
  48.    easytegl();
  49.    easyout();
  50.  
  51.    pushimage(10,10,100,35);
  52.    shadowbox(10,10,100,35);
  53.    timefs = stackptr;
  54.    settimertick(18,inc_time,timefs,NULL);
  55.  
  56.    teglsupervisor();
  57. }
  58.